package io.kubesphere.devops.dao;

import io.kubesphere.devops.model.UserMergingDetail;
import io.kubesphere.devops.model.UserMergingRule;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMergingDetailDao {

    /**
     * user_merging_detail_id
     * user_merging_id
     * user_merging_timestamp
     * datasource_id
     * status
     * <p>
     *
     * @param detail
     * @return
     */
    @Insert(
            "INSERT INTO user_merging_detail " +
                    "(user_merging_detail_id, user_merging_id," +
                    "user_merging_timestamp,datasource_id,status)" +
                    " VALUES (#{userMergingDetailId}, #{userMergingId}, "
                    + " #{userMergingTimestamp}, #{datasourceId}, #{status})")
    Integer saveMergingDetail(UserMergingDetail detail);

    @Select("SELECT user_merging_detail_id userMergingDetailId, user_merging_id userMergingId, datasource_id datasourceId, user_merging_timestamp userMergingTimestamp, status status " +
            "FROM user_merging_detail where user_merging_id =#{userMergingId}")
    List<UserMergingDetail> getByMergingId(String userMergingId);

    @Update("update user_merging_detail set status = #{status} where user_merging_detail_id = #{userMergingDetailId}")
    void updateStatus(String userMergingDetailId,String status);
}
